//商品刷新功能
create_table = (arr) =>{
  $(".content-box")[0].innerHTML = "";
  let str = "";
  for( let i = 0;i < arr.length;i++ ){
          //获取商品的名称、商品的价格、商品的存储路径
          let o_name = arr[i].pro_name;
          let o_price = arr[i].pro_price;
          let o_imgpath = arr[i].pro_imgpath;
        //   console.log(o_name);
        //   console.log(o_price);
        //   console.log(o_imgpath);

          str = `<div>
                        <div><a href=""><img src="${o_imgpath}" alt=""></a></div>
                        <div>
                            <a href="">
                                <div>${o_name}</div>
                                <div>${o_price}</div>
                                <input type="button" value="立即购买" name="buy">
                            </a>
                            <input type="button" value="收藏" name="store">
                        </div>
                  </div>`;
                  $(".content-box")[0].innerHTML += str;
  }
}


//刷新页面
//获取本地数据
let oLoac = localStorage.getItem("sear");

//创建xhr对象
 let xhr = new XMLHttpRequest();

 //实现open方法
 xhr.open( "get","./api/get_ssresultdata.php?pro_name"+oLoac,true );

 //发送请求
 xhr.send();

 //设置监听状态
 xhr.onreadystatechange = function(){
     if( xhr.readyState === 4 && xhr.status === 200 ){
         let arr = JSON.parse( xhr.responseText );
         console.log(  xhr.responseText  );
         create_table( arr );
     }
 }